#!/usr/bin/env node

const http= require('http');
const url = require('url');
const addr ='http://www.baidu.co://gitee.com/api/v5/users/${users}/repos?access_token=55e20de950250847bb9f1f1e19b3bc80&type=all&sort=full_name&page=1&per_page=20';
const options = url.parse(addr);
options.headers={
  'User-Agent':'02-get-repos.js'
};

http.get(options,(res)=>{
  console.log(`HTTP/${res.httpVersion} ${res.statusCode} ${res.statusMessage}`);
  console.log(res.headers);
  console.log();
  res.pipe(process.stdout);

  let data = '';
  res.on('data',(chunk)=>{
    data += chunk;
  });
  res.on('end',()=>{
    data = JSON.parse(data);
    for(const respos of data){
      console.log(respos.full_name);
    }
  });
});
